package com.he.producer;

import com.he.constant.RabbitmqConstant;
import com.he.domain.dto.ArticleViewMessage;
import jakarta.annotation.Resource;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author He
 * @version 1.0
 * @Date 2023/9/19 23:08
 * @Desc Redis生产者
 */
@Service
public class RedisSyncProducer {

    @Resource
    private RabbitTemplate rabbitTemplate;

    /**
     * 发送更新文章浏览量消息
     * @param articleViewMessage 文章浏览量消息
     */
    public void sendUpdateArticleViewCountMessage(ArticleViewMessage articleViewMessage){
        rabbitTemplate.convertAndSend(RabbitmqConstant.REDIS_SYNC_EXCHANGE,RabbitmqConstant.ARTICLE_VIEW_QUEUE,articleViewMessage);
    }

    /**
     * 更新有关Redis的缓存
     */
    public void sendUpdateArticleCatchMessage(){
        rabbitTemplate.convertAndSend(RabbitmqConstant.REDIS_SYNC_EXCHANGE,RabbitmqConstant.ARTICLE_CACHE_QUEUE,"");
    }


}
